package com.fer.tankr.models.powerups;

import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.fer.andenginemvc.api.gameObjects.GameObject;
import com.fer.andenginemvc.api.gameObjects.Powerup;
import com.fer.tankr.models.Tank;

public class ChangeLevel extends Powerup {

	private IChangeLevelHandler changeLevelHandler;
	private int level;
	
	public ChangeLevel(PhysicsWorld world, VertexBufferObjectManager vbom,
			float x, float y, ITextureRegion texture, int level) {
		super(world, vbom, x, y);
		this.entity.setAlpha(0.4f);
		this.level = level;
	}
	
	@Override
	public void onCollision(GameObject<?> go) {
		super.onCollision(go);
		if (go instanceof Tank)
		{
			if (changeLevelHandler != null)
			{
				changeLevelHandler.onChangeLevel(level);
			}
		}
	}
	
	public void setChangeLevelHandler(IChangeLevelHandler handler)
	{
		this.changeLevelHandler = handler;
	}
	
	public interface IChangeLevelHandler
	{
		public void onChangeLevel(int level);
	}

}
